package com.oracle.config;

import com.oracle.common.Constant;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @program: CampusMatching
 * @description:地址映射
 * @author: zhaolei
 * @create: 2020-07-31 17:09
 **/
@Configuration
public class WebMVcConfig implements WebMvcConfigurer {
    /**
     * 配置的图片映射
     */
    private static final String imgPath = "file:" + Constant.UPLOAD_PATH + Constant.IMG_FILE_NAME +  "/";

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //将所有访问img/virtual/**的请求映射到文件上传的路径下 D:\temp2/img（图片的保存路径）
        registry.addResourceHandler("/img/virtual/**").addResourceLocations(imgPath);

    }

}
